/* rewoxr.p - Repetitive Production Responsibility-Owning Procedure           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5 $                                                           */
/*                                                                            */
/* Revision: 1.4    BY:hze           DATE:07/12/00  ECO: *N0DK*               */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00 BY: *N0KP* myb                    */
/* REVISION: 9.1    LAST MODIFIED: 08/21/00 BY: *N0LJ* Mark Brown             */
/* $Revision: 1.5 $     BY: Murali Ayyagari   DATE: 12/01/00  ECO: *N0V1*      */
/*                                                                            */
/*V8:ConvertMode=NoConvert                                                    */
/*                                                                            */


/* ========================================================================== */
/* ******************************* DEFINITIONS ****************************** */
/* ========================================================================== */

/* STANDARD INCLUDE FILES */
{mfdeclre.i}
{pxmaint.i}

/* Define Handles for the programs. */
{pxphdef.i wowrxr}
/* End Define Handles for the programs. */


/* ========================================================================== */
/* ******************************* MAIN BLOCK ******************************* */
/* ========================================================================== */

/* ========================================================================== */
/* ******************************** FUNCTIONS ******************************* */
/* ========================================================================== */


/*============================================================================*/
FUNCTION isRepetitiveProduction RETURNS logical
   (input pWorkOrderType as character,
   input pWorkOrderNumber as character):
/*------------------------------------------------------------------------------
Purpose:       determines if it is a repetitive production.
rewoxr.p
isRepetitiveProduction RETURNS logical (
   input character pWorkOrderType,
   input character pWorkOrderNumber)

Parameters:
   pWorkOrderType -
   pWorkOrderNumber -

Exceptions:

PreConditions:

PostConditions:

</Comment1>
<Comment2>
Notes:

</Comment2>
<Comment3>
History:

</Comment3>
------------------------------------------------------------------------------*/
   define variable returnData as logical no-undo.

   if pWorkOrderType = "c" and pWorkOrderNumber = "" then
      returnData = True.
   else
      returnData = False.

   return (returnData).
END FUNCTION.

/* extract from rechkq.p */
/* ========================================================================== */
/* *************************** INTERNAL PROCEDURES ************************** */
/* ========================================================================== */


/*hze*/
/*============================================================================*/
PROCEDURE validateQueueQty :
/*------------------------------------------------------------------------------
<Comment1>
rewoxr.p
validateQueueQty (
   input character pWorkOrderId,
   input integer pWorkOrderOperation,
   input character pQueueType,
   input decimal pQuantityChange)

Parameters:
   pWorkOrderId -
   pWorkOrderOperation -
   pQueueType -
   pQuantityChange -

Exceptions:

PreConditions:

PostConditions:

</Comment1>
<Comment2>
Notes:

</Comment2>
<Comment3>
History:

</Comment3>
------------------------------------------------------------------------------*/
   define input parameter pWorkOrderId as character no-undo.
   define input parameter pWorkOrderOperation as integer no-undo.
   define input parameter pQueueType as character no-undo.
   define input parameter pQuantityChange as decimal no-undo.

   define variable first_op as logical no-undo.
   define buffer bWr_route for wr_route.

   do on error undo, return error {&GENERAL-APP-EXCEPT}:

      {pxrun.i &PROC='readOperationForFirstWOID' &PROGRAM='wowrxr.p'
                &HANDLE=ph_wowrxr
               &PARAM="(input pWorkOrderId,
                        input pWorkOrderOperation,
                        buffer bWr_route,
                        input {&NO_LOCK_FLAG},
                        input {&NO_WAIT_FLAG})"
      }

    {pxgetph.i wowrxr}

    if pQueueType = "i" and
       not {pxfunct.i &FUNCTION='isFirstOperationForWOID' &PROGRAM='wowrxr.p'
                        &PARAM="input pWorkOrderId,
                                input pWorkOrderOperation"}
    then do:
         /*CHECK INPUT QUEUE*/
      if wr_qty_inque + pQuantityChange < 0 then do:
          /* input queue quantity will become negative at operation */
           {pxmsg.i &MSGNUM=5114
                    &ERRORLEVEL={&WARNING-RESULT}
                    &MSGARG1=string(wr_op)
           }
           return {&WARNING-RESULT} .
      end.
    end.
    else if pQueueType = "o" then do:
        /*CHECK OUTPUT QUEUE*/
       if wr_qty_outque + pQuantityChange < 0 then do:
          /* output queue quantity will become negative at operation */
           {pxmsg.i &MSGNUM=5115
                    &ERRORLEVEL={&WARNING-RESULT}
                    &MSGARG1=string(wr_op)
           }
           return {&WARNING-RESULT} .
       end.
    end.
    else if pQueueType = "r" then do:
       /*CHECK REJECT QUEUE*/
       if wr_qty_rejque + pQuantityChange < 0 then do:
          /* reject queue quantity will become negative at operation */
           {pxmsg.i &MSGNUM=5117
                    &ERRORLEVEL={&WARNING-RESULT}
                    &MSGARG1=string(wr_op)
           }
           return {&WARNING-RESULT} .
       end.
    end.

   end.
   return {&SUCCESS-RESULT}.
END PROCEDURE.
